package com.bit.mybatis.controller;

import com.bit.mybatis.modle.UserInfo;
import com.bit.mybatis.service.UserInfoService;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/user")
@RestController
public class UserInfoController {
    @Autowired
    private UserInfoService userInfoService;
    @RequestMapping("/getAllUser")
    public List<UserInfo> getAllUser(){
         return userInfoService.setAllUser();
    }
    //实际开发过程中底代码的正确测试；
    @RequestMapping("/getAllUserById")
    public UserInfo getAllUserById(Integer id){
        return userInfoService.getAllUserById(id);
    }
    //进行SQL注入的相关错误的练习与验证；
    @RequestMapping("/login")
    public boolean login(String userName,String password){
        UserInfo userInfo=userInfoService.queryMysqlByUserNameAndPassword(userName,password);
        return userInfo==null ? false : true;
    }
}
